%% CALCULATESNR FUNCTION
% Author: Mathieu Boudreau
% Date Created: March 20rd 2012
% Date Modified: April 17th 2012 by Mathieu Boudreau
%
% Calculates the mean signal to noise (standard deviation) ratio from user
% selected signal and noise region of interests of loaded image.
%
% This function calls another custom function called "roiStats".
%
% The function outputs are the SNR (signalToNoise) and the mean and 
% standard deviations of both image regions (contained in allStats).

function [ signalToNoise, allStats ] = calculateSNR( imageData )
    
    % Load image
    figure()
    imagesc(imageData)
    
    % Select noise ROI
    waitfor(msgbox('Please select the ROI for noise by clicking - drag to the left and down - and then double click on the lower right corner', 'calculateSNR Function'));
    [stdNoise, meanNoise]=roiStats(imageData);
    
    % Select signal ROI
    waitfor(msgbox('Please select the ROI for the signal by clicking - drag to the left and down - and then double click on the lower right corner', 'calculateSNR Function'));
    [stdSignal, meanSignal]=roiStats(imageData);
    
    signalToNoise=meanSignal/stdNoise;
    
    allStats = [stdNoise, meanNoise; stdSignal, meanSignal];

end

